{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}

<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>

<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th data-align="center"></th>
                                    <th data-align="center">次数</th>
                                    <th data-align="center"></th>
                                    <th data-align="center">最小</th>
                                    <th data-align="center">最大</th>
                                    <th data-align="center"></th>
                                    <th data-align="center">操作</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td>
                                        今日有效打卡第
                                    </td>
                                    <td>
                                        {$v.num}次
                                    </td>
                                    <td>
                                        可获得
                                    </td>
                                    <td>
                                        <input type="text" class="form-control minchange" placeholder="最小" onchange="minchange('{$v.id}')" value="{$v.min}" name="min">
                                    </td>
                                    <td>
                                        <input type="text" class="form-control maxchange" placeholder="最大" onchange="maxchange('{$v.id}')" value="{$v.max}" name="max">
                                    </td>
                                    <td>
                                        金币
                                    </td>
                                    <td>
                                        <A class="btn btn-danger btn-xs" onclick="dele('{$v.num}')">删除</A>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}

<script type="text/javascript">

    function dele(num)
    {
        let url = "{:url('realsignconfigdele')}"
        swal({
            title: "如果存在后续次数，则一并删除",
            text: "操作后将无法恢复，请谨慎操作！",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
        },
        function(isConfirm) {
            if (isConfirm) {
                var index = layer.load(1, {
                 shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                ajaxFun("post",url,{num:num},'json',function(ret){
                    if(ret){
                        if(ret.ret){
                          setTimeout(()=>{
                            swal_msg(ret.ret,'','success',1)
                          }, 100)
                        }else{
                            layer.msg(ret.err)
                        }
                    }else{
                        swal_msg("错误",ret,"error");
                    }
                    layer.close(index); 
                })
            }
        })
    }
    function maxchange(id){
        var val = $('#id'+id).find('.maxchange').val();
        $.ajax({
            type: 'post',
            url: '{:url("realsignmaxchange")}',
            data: {id:id,data:val},
            dataType: 'json',
            success:function(ret){
                if (ret.ret) {
                    layer.msg('设置成功')
                } else {
                    $('#id'+id).find('.maxchange').val(ret.val);
                    layer.msg(ret.err);
                }
            },
            error:function(err){
                layer.msg(err)
            }
        });
    }
    function minchange(id){
        var val = $('#id'+id).find('.minchange').val();
        $.ajax({
            type: 'post',
            url: '{:url("realsignminchange")}',
            data: {id:id,data:val},
            dataType: 'json',
            success:function(ret){
                if (ret.ret) {
                    layer.msg('设置成功')
                } else {
                    $('#id'+id).find('.minchange').val(ret.val);
                    layer.msg(ret.err);
                }
            },
            error:function(err){
                layer.msg(err)
            }
        });
    }

</script>
